package com.chaihu.common.dao;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.toolkit.Constants;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.chaihu.bean.dto.user.UserDto;
import com.chaihu.core.base.mapper.SuperMapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public interface UserDao extends SuperMapper<UserDto> {
    List<UserDto> selectRaw();

    // SQL中不写WHERE关键字，且固定使用${ew.customSqlSegment}
    @Select("select * from user ${ew.customSqlSegment}")
    List<UserDto> findAll(@Param(Constants.WRAPPER) Wrapper<UserDto> wrapper);

    // 这里采用纯注解方式。当然，若SQL比较复杂，建议还是采用XML的方式
    @Select("SELECT * FROM user ${ew.customSqlSegment}")
    Page<UserDto> selectUserDtoPage(Page<UserDto> page, @Param(Constants.WRAPPER) Wrapper<UserDto> wrapper);
}